package com.caterina.components;

import java.awt.Dimension;

import com.caterina.activityManager.CActivity;

import controllers.ManagerTask.TaskType;
//import com.caterina.resources.CWords;

public class CActivityPane extends CFrame{
	public CActivityPane(CActivity contentActivity){
		super(contentActivity);
		super.getActivity().setCBarQueryesEnabled(false);
		super.getActivity().setCBarVisible(false);
		super.start();
		super.setMinimumSize(new Dimension(0,0));
		//super.setPreferredSize(contentActivity.getActivitySize());
		super.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
		//super.setMaximumSize(contentActivity.getActivitySize());
	}
	public void dispose(){
		if(ownerActivity!=null)ownerActivity.setEnabled(true);
		super.dispose();
	}
	public void send(TaskType task,Object objectToSend){
		if(ownerActivity!=null){
			if(objectToSend!=null){
				if(objectToSend instanceof Exception)ownerActivity.onError(task, (Exception) objectToSend);
				else ownerActivity.onData(task, objectToSend);
			}
		}
	}
	public void sendAndDispose(TaskType task,Object objectToSend){
		this.send(task,objectToSend);
		this.dispose();
	}
	
	public CActivity getOwnerActivity(){
		return this.ownerActivity;
	}
	private CActivity ownerActivity;
	private static final long serialVersionUID = 1L;
}
